﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Internal;
using Prism.Services.Dialogs;
using SmartPlant.Model;
using SmartPlant.Model.Biz;
using SmartPlant.Services.Interfaces;
using SmartPlant.WinCore;

namespace SmartPlant.Core.ViewModels
{
    public class RenameViewModel : SmartDialogBase
    {
        public string Id { get; set; }
        public string oldName { get; set; }
        public ObjectDefId ObjectDefId { get; set; }
        private string _newName;

        public string newName
        {
            get { return _newName; }
            set { _newName = value; }
        }


        private bool isBusy = true;
        public bool IsBusy
        {
            get { return isBusy; }
            set
            {
                isBusy = value;
                RaisePropertyChanged();
            }
        }
        public decimal _proId { get; set; }
        public decimal _unitId { get; set; }
        private readonly IDialogService dialogService;

        public RenameViewModel(IDialogService dialogService, IUnitTagConvService unitTagConv, IInstrumentService instrumentService)
        {
            _proId = GlobalObject.CurrentProject.ProjId;
            this.dialogService = dialogService;
        }
        /// <summary>
        /// 确认按钮
        /// </summary>
        /// <param name="parameter"></param>
        public override async void ExecuteCloseDialogCommand(string parameter)
        {
            IsBusy = true;
            #region 核心
            switch (ObjectDefId)
            {
                case ObjectDefId.equipment:
                    break;
                case ObjectDefId.component:
                    break;
                case ObjectDefId.line:
                    break;
                case ObjectDefId.softTag:
                    break;
                case ObjectDefId.ddp:
                    break;
                case ObjectDefId.pd://更新drawing表和object registry表

                    break;
                case ObjectDefId.spec:
                    break;
                case ObjectDefId.pd102:
                    break;
                case ObjectDefId.loop:
                    break;
                default:
                    break;
            }
            #endregion
            ButtonResult result = ButtonResult.None;
            DialogParameters parameters = new DialogParameters();
            result = ButtonResult.Yes;
            RraiseRequestClose(new DialogResult(result, parameters));
            IsBusy = false;
        }

        public override async void OnDialogOpened(IDialogParameters parameters)
        {
            Id = parameters.GetValue<string>(DialogParameterKeys.Id);
            oldName = parameters.GetValue<string>(DialogParameterKeys.Content);
            ObjectDefId = parameters.GetValue<ObjectDefId>(DialogParameterKeys.ObjectType);

            base.OnDialogOpened(parameters);
            IsBusy = false;
        }
    }
}
